package cn.itcast.rnk.io;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class CopyBuffer {

	public static void main(String[] args) {
		BufferedReader reader  =null;
		BufferedWriter writer = null;
		try {
			reader= new BufferedReader(new FileReader("xanadu.txt")) ;
			writer = new BufferedWriter(new FileWriter("bufferwriteoutput.txt"));

			String l;
			while (( l = reader.readLine())!=null) {
				writer.write(l);

			}

		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally {
			if (reader!=null) {
				try {
					reader.close();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			if (writer!=null) {
				try {
					writer.close();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
	}

}
